# coding:utf-8
from appium import webdriver
from time import sleep
from case.start_appium import get_device
# caps = {}
# caps["platformName"] = "android"
# caps["deviceName"] = "127.0.0.1:62001"
# caps["appPackage"] = "com.HaiwellCloud"
# caps["appActivity"] = "com.dosingle.MainActivity"
# caps["autoGrantPermissions"] = True
# caps["skipServerInstallation"] = True
# caps["skipDeviceInitialization"] = True
# caps["noReset"] = True
# caps["ensureWebviewsHavePages"] = True
#
# device =webdriver.Remote("http://localhost:4723/wd/hub", caps)
# device.implicitly_wait(10)
# sleep(5)

# 获取屏幕的宽高
def get_size():
    size = device.get_window_size()  # 获取屏幕的width和height
    width = size['width']
    height = size['height']
    return width,height
# 向左滑动
def swipe_left():
    x1 = get_size()[0]/10*9
    y1 = get_size()[1]/2
    x = get_size()[0]/10
    device.swipe(x1,y1,x,y1,)
# 向右滑动
def swipe_right():
    x1 = get_size()[0]/10*9
    y1 = get_size()[1]/2
    x = get_size()[0]/10
    device.swipe(x,y1,x1,y1)
# 向上滑动
def swipe_up():
    x1 = get_size()[0]/2
    y1 = get_size()[1]/10*9
    y = get_size()[1]/10
    device.swipe(x1,y1,x1,y)

# 向下滑动
def swipe_down():
    x1 = get_size()[0]/2
    y1 = get_size()[1]/10*9
    y = get_size()[1]/10
    device.swipe(x1,y,x1,y1,)

def swipe_on(diretion):
    if diretion == 'left':
        swipe_left()
    elif diretion == 'right':
        swipe_right()
    elif diretion == 'up':
        swipe_up()
    else:
        swipe_down()
device =get_device()
swipe_on('up')
swipe_on('right')




